package controller.controller;
import Model.DAO;
import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import java.util.List;

public class MainActivity extends ListActivity
{
    /** Called when the activity is first created. */
    @Override
    protected void onListItemClick(ListView l, View v, int position, long id) {
        //Toast.makeText(getApplicationContext(), "Bonjour " + l.getItemAtPosition(position), Toast.LENGTH_LONG).show();
        Intent inter = new Intent(this, MedActivity.class);
        inter.putExtra("leNom", l.getItemAtPosition(position).toString());
        startActivity(inter);
    }
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
          //lecture des noms
        List<String> lesNoms = DAO.getLesDep();
        //creation de l'adapter
        ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, lesNoms);
        setListAdapter(adapter);
    }
}
